<template>
  <div class="w1200">
    <div v-if="articles.length === 0" style="height: 300px;display: flex;align-items: center;justify-content: center;">{{$t('暂未内容，敬请期待！')}}</div>
    <div v-else @click="openUrl(article.url)" v-for="(article,key) in articles" :key="key" class="top" style="">
      <div class="img" :style="{ backgroundImage: `url(${article.img_url})` }"></div>
      <div class="text">
          <!--          <div class="ico">头条</div>-->
          <div class="t1">{{ article.title}}</div>
          <div class="t2" v-html="article.content">
          </div>
      </div>
    </div>
  </div>
</template>
<script>
import NewsImg from '@/assets/images/news_img_03.jpg'
import apiService from "@/api/apiService";
export default {
  // eslint-disable-next-line vue/multi-word-component-names
  name: 'News',
  data() {
    return {
      NewsImg,
      articles:[],
    }
  },
  created() {
    this.getPageFreepublish()
  },
    computed:{

    },
  methods:{
      openUrl(url){
          window.open(url, '_blank');
      },
    getPageFreepublish(){
      apiService.post("/freepublish", {
        pageNumber:0,
        pageSize:10,
      }).then((res) => {
        this.articles = res.data
      });
    }
  }
}
</script>
<style lang="scss" scoped>

.top:hover{
    box-shadow: #1A79FF;
}
.top {
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;

  .img {
    width: 450px;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    height: 100%;
  }

  .text {
    flex: 1;
    height: 100%;
    background-color: #f6f7f8;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding-left: 40px;
    padding-right: 40px;

    .t1 {
      font-size: 24px;
      color: #333;
    }

    .t2 {
      font-size: 14px;
      color: #666;
      margin-top: 20px;
      line-height: 30px;
      height: 90px;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 3;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .ico {
      position: absolute;
      right: 0;
      top: 0;
      width: 100px;
      height: 60px;
      background-color: #fc802d;
      display: flex;
      align-items: flex-end;
      justify-content: center;
      font-size: 14px;
      color: #fff;
      padding-bottom: 4px;
      transform: rotate(45deg) translate(15px, -50px);
    }
  }
}


.top {
    border: 0;
    background: none;
    text-transform: uppercase;
    color: #43e5ee;
    font-weight: bold;
    position: relative;
    outline: none;
    margin-top: 10px;
    margin-bottom: 30px;
    padding: 5px 5px;
    box-sizing: border-box;
}

.top:hover{

    box-shadow: 0 0 22px #0e6eb8;
}

.top::before, .top::after {
    box-sizing: inherit;
    position: absolute;
    content: '';
    border: 3px solid transparent;
    width: 0;
    height: 0;
}

.top::after {
    bottom: 0;
    right: 0;
}

.top::before {
    top: 0;
    left: 0;
}

.top:hover::before, .top:hover::after {
    width: 100%;
    height: 100%;
}

.top:hover::before {
    border-top-color: #1ffff4;
    border-right-color: #1bc5ff;
    transition: width 0.1s ease-out, height 0.1s ease-out 0.1s;
}

.top:hover::after {
    border-bottom-color: #198fff;
    border-left-color: #4361ee;
    transition: border-color 0s ease-out 0.1s, width 0.1s ease-out 0.1s, height 0.1s ease-out 0.2s;
}
</style>